package com.tridion.utilities.verifier.analyzer;

import java.io.File;

import com.tridion.utilities.verifier.model.ContentDeliveryInstallation;
import com.tridion.utilities.verifier.utils.Constants;

/**
 * Analyzer that sets the lib/config folders.
 * 
 * @author Daniel Neagu
 */
public class FoldersAnalyzer implements Analyzer {

    /**
     * Sets the lib/config folders depending on the {@link ContentDeliveryInstallation} type.
     */
    @Override
    public void analyze(final ContentDeliveryInstallation cdi) {
        final File rootFolder = cdi.getRootLocation();
        
        // depending on the type we set folders to different values
        switch (cdi.getType()) {
            case JAVA_WEB_APPLICATION:
                cdi.setLibFolder(new File(rootFolder, Constants.JAVA_WEB_APP_LIB_FOLDER));
                cdi.setConfigFolder(new File(rootFolder, Constants.JAVA_WEB_APP_CONFIG_FOLDER));
                break;
            case DOT_NET_WEB_APPLICATION:
                cdi.setLibFolder(new File(rootFolder, Constants.DOT_NET_WEB_APP_LIB_FOLDER));
                cdi.setConfigFolder(new File(rootFolder, Constants.DOT_NET_WEB_APP_CONFIG_FOLDER));
                break;
            case WINDOWS_SERVICE:
                cdi.setLibFolder(new File(rootFolder, Constants.WINDOWS_SERVICE_LIB_FOLDER));
                cdi.setConfigFolder(new File(rootFolder, Constants.WINDOWS_SERVICE_CONFIG_FOLDER));
                break;
            default:
                // TODO:
                break;
        }
    }
}
